package org.at;

import java.math.BigDecimal;

public class Strawberry extends Fruit{
    // 大小
    private String size;

    // 是否有机
    private boolean organic;

    public Strawberry(BigDecimal price, BigDecimal discountRate, String size, boolean organic) {
        if (discountRate.compareTo(BigDecimal.ZERO) <=0  || discountRate.compareTo(BigDecimal.ONE) > 0) {
            throw new IllegalArgumentException("折扣必须在0到1区间");
        }
        this.name = "草莓";
        this.price = price;
        this.discountRate = discountRate;
        this.size = size;
        this.organic = organic;
    }

    @Override
    public String getDescription() {
        String organicInfo = organic ? "有机种植" : "";
        return String.format("%s鲜红饱满的%s,%s果粒%s",organicInfo, name, name, size);
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public boolean isOrganic() {
        return organic;
    }

    public void setOrganic(boolean organic) {
        this.organic = organic;
    }
}
